<template>
  <div class="photoShare">
    <van-tabs v-model="active" animated>
      <van-tab v-for="item in cates" :title="item.title" :key="item.id">
        
      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
import { Toast } from "vant";
import { Lazyload } from "vant";
export default {
  data() {
    return {
      id: "",
      active: "",
      cates: [],
      imageList: []
    };
  },
  created() {
    this.getPhotoCategory();
    // 默认获取“全部” 那一项的图片
    this.getImg(0)
  },
  methods: {
    getPhotoCategory() {
      this.$http
        .get("http://www.liulongbin.top:3005/api/getimgcategory")
        .then(res => {
          if (res.data.status == 0) {
            // 手动添加 “全部 “ 这条数据
            res.data.message.unshift({ title: "全部", id: 0 });
            this.cates = res.data.message;
            //   console.log(this.cates);
          }
        })
        .catch(function(error) {
          // handle error
          Toast("获取分类列表失败");
        });
    },
    getImg(cateId) {
      this.$http
        .get("http://www.liulongbin.top:3005/api/getimages/" + cateId)
        .then(res => {
          if (res.data.status == 0) {
           
              console.log(this.data.message);
          }
        })
        .catch(function(error) {
          // handle error
          Toast("获取图片失败");
        });
    }
  }
};
</script>
<style lang="less" scoped>
.photoShare {
  li {
    width: 100%;
    height: 100%;
    img {
      width: 100%;
      height: 100%;
    }
  }
}
</style>